package com.tjhzzx.hnceCore2024.command;


import com.tjhzzx.hnceCore2024.servlet.AbstractServletCommand;
import com.tjhzzx.hnceCore2024.servlet.impl.BHnxWebService;

import javax.baja.collection.BITable;
import javax.baja.collection.TableCursor;
import javax.baja.naming.BOrd;
import javax.baja.sys.BIObject;
import javax.baja.sys.Sys;
import javax.baja.web.WebOp;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Luc
 * @date 2020-02-02 14:56 
 * @version 1.0
 */
public class HnxWebServerCommand extends AbstractServletCommand {

    public void getInstanceInJson(WebOp op, String queryString) {
        StringBuilder bql = new StringBuilder();
        bql.append("station:|slot:/Services|bql:select * from hnceCore2024:HnxWebService");
        List<BHnxWebService> webServices = new ArrayList<>();
        BOrd ord = BOrd.make(bql.toString());
        BITable<BIObject> webServerTable = (BITable<BIObject>) ord.get(Sys.getStation());
        try (TableCursor<BIObject> cursor = webServerTable.cursor()) {
            while (cursor.next()) {
                BHnxWebService webService = (BHnxWebService) cursor.get();
                webServices.add(webService);
            }
        }
    }
}
